home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreateWake.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.7 KB  |  309 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Feb 2002
  22. //  Author:         dbrins 
  23. //
  24. //  Description:
  25. //
  26. //  Option box for the createWake command 
  27. //
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     if ($forceFactorySettings || !`optionVar -exists createWakeIntensity`) {
  45.         optionVar -floatValue createWakeIntensity 5.0;
  46.     }
  47.     if ($forceFactorySettings || !`optionVar -exists createWakeFoam`) {
  48.         optionVar -floatValue createWakeFoam 0.0;
  49.     }
  50. }
  51.  
  52. //
  53. //  Procedure Name:
  54. //      createWakeSetup
  55. //
  56. //  Description:
  57. //        Update the state of the option box UI to reflect the option values.
  58. //
  59. //  Input Arguments:
  60. //      parent               - Top level parent layout of the option box UI.
  61. //                             Required so that UI object names can be 
  62. //                             successfully resolved.
  63. //
  64. //    forceFactorySettings - Whether the option values should be set to
  65. //                             default values.
  66. //
  67. //  Return Value:
  68. //      None.
  69. //
  70. global proc createWakeSetup(string $parent, int $forceFactorySettings)
  71. {
  72.     //    Retrieve the option settings
  73.     //
  74.     setOptionVars($forceFactorySettings);
  75.  
  76.     setParent $parent;
  77.  
  78.     //    Query the optionVar's and set the values into the controls.
  79.  
  80.     floatSliderGrp -edit 
  81.         -v `optionVar -query createWakeIntensity`
  82.         createWakeIntensity;
  83.  
  84.     floatSliderGrp -edit 
  85.         -v `optionVar -query createWakeFoam`
  86.         createWakeFoam;
  87.  
  88. }
  89.  
  90. //
  91. //  Procedure Name:
  92. //      createWakeCallback
  93. //
  94. //  Description:
  95. //        Update the option values with the current state of the option box UI.
  96. //
  97. //  Input Arguments:
  98. //      parent - Top level parent layout of the option box UI.  Required so
  99. //               that UI object names can be successfully resolved.
  100. //
  101. //    doIt   - Whether the command should execute.
  102. //
  103. //  Return Value:
  104. //      None.
  105. //
  106. global proc createWakeCallback(string $parent, int $doIt)
  107. {
  108.     setParent $parent;
  109.  
  110.     //    Set the optionVar's from the control values, and then
  111.     //    perform the command.
  112.  
  113.     optionVar -floatValue createWakeIntensity
  114.         `floatSliderGrp -query -v createWakeIntensity`;
  115.     optionVar -floatValue createWakeFoam
  116.         `floatSliderGrp -query -v createWakeFoam`;
  117.  
  118.     if ($doIt) {
  119.         performCreateWake 0;
  120.     }
  121. }
  122.  
  123. //
  124. //  Procedure Name:
  125. //      createWakeOptions
  126. //
  127. //  Description:
  128. //        Construct the option box UI.  Involves accessing the standard option
  129. //        box and customizing the UI accordingly.
  130. //
  131. //  Input Arguments:
  132. //      None.
  133. //
  134. //  Return Value:
  135. //      None.
  136. //
  137. proc createWakeOptions()
  138. {
  139.     //    Name of the command for this option box.
  140.     //
  141.     string $commandName = "createWake";
  142.  
  143.     //    Build the option box actions.
  144.     //
  145.     string $callback = ($commandName + "Callback");
  146.     string $setup = ($commandName + "Setup");
  147.  
  148.     string $layout = getOptionBox();
  149.     setParent $layout;
  150.     
  151.     setOptionBoxCommandName($commandName);
  152.     
  153.     setUITemplate -pushTemplate DefaultTemplate;
  154.  
  155.     waitCursor -state 1;
  156.  
  157.     tabLayout -tabsVisible 0 -scrollable 1;
  158.     
  159.     string $parent = `columnLayout -adjustableColumn 1`;
  160.     
  161.     floatSliderGrp
  162.         -label "Wake Intensity"
  163.         -cw 4  150
  164.         -field 1
  165.         -min 0.0 
  166.         -max 10.0 
  167.         -fieldMinValue 0.0 
  168.         -fieldMaxValue 1000000.0
  169.         -pre 2
  170.         -el "(Density/Voxel/Sec)"
  171.         createWakeIntensity;
  172.  
  173.     floatSliderGrp
  174.         -label "Foam Creation"
  175.         -cw 4 150
  176.         -field 1
  177.         -min 0.0 
  178.         -max 10.0 
  179.         -fieldMinValue 0.0 
  180.         -fieldMaxValue 1000000.0
  181.         -pre 2
  182.         -el "(Heat/Voxel/Sec)"
  183.         createWakeFoam;
  184.  
  185.     waitCursor -state 0;
  186.     
  187.     setUITemplate -popTemplate;
  188.  
  189.     //    'Create' button.
  190.     //
  191.     string $applyBtn = getOptionBoxApplyBtn();
  192.     button -edit
  193.         -label "Create Wake"
  194.         -command ($callback + " " + $parent + " " + 1)
  195.         $applyBtn;
  196.  
  197.     //    'Save' button.
  198.     //
  199.     string $saveBtn = getOptionBoxSaveBtn();
  200.     button -edit 
  201.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  202.         $saveBtn;
  203.  
  204.     //    'Reset' button.
  205.     //
  206.     string $resetBtn = getOptionBoxResetBtn();
  207.     button -edit 
  208.         -command ($setup + " " + $parent + " " + 1)
  209.         $resetBtn;
  210.  
  211.     setOptionBoxTitle("Create Wake");
  212.  
  213.     //    Customize the 'Help' menu item text.
  214.     //
  215.     setOptionBoxHelpTag( "CreateWake" );
  216.  
  217.     eval (($setup + " " + $parent + " " + 0));    
  218.     
  219.     showOptionBox();
  220. }
  221.  
  222. //
  223. //  Procedure Name:
  224. //      createWakeHelp
  225. //
  226. //  Description:
  227. //        Return a short description about this command.
  228. //
  229. //  Input Arguments:
  230. //      None.
  231. //
  232. //  Return Value:
  233. //      string.
  234. //
  235. proc string createWakeHelp()
  236. {
  237.     return 
  238.     "  Command: createWake - Make selected objects generate wakes on the ocean.\n" +
  239.     "Selection: objects to emit wakes";
  240. }
  241.  
  242. //
  243. //  Procedure Name:
  244. //      assembleCmd
  245. //
  246. //  Description:
  247. //        Construct the command that will apply the option box values.
  248. //
  249. //  Input Arguments:
  250. //      None.
  251. //
  252. proc string assembleCmd()
  253. {
  254.     string $cmd = "createWake";
  255.  
  256.     setOptionVars(false);
  257.  
  258.     $cmd = ($cmd
  259.         + " " + `optionVar -query createWakeIntensity` 
  260.         + " " + `optionVar -query createWakeFoam` 
  261.         );
  262.  
  263.     return $cmd;
  264. }
  265.  
  266. //
  267. //  Procedure Name:
  268. //      performCreateWake
  269. //
  270. //  Description:
  271. //        Perform the createWake command using the corresponding 
  272. //        option values.
  273. //
  274. //  Input Arguments:
  275. //      0 - Execute the command.
  276. //      1 - Show the option box dialog.
  277. //      2 - Return the command.
  278. //
  279. global proc string performCreateWake(int $action)
  280. {
  281.     string $cmd = "";
  282.  
  283.     switch ($action) {
  284.  
  285.         //    Execute the command.
  286.         //
  287.         case 0:
  288.             $cmd = `assembleCmd`;
  289.             eval($cmd);
  290.             break;
  291.  
  292.         //    Show the option box.
  293.         //
  294.         case 1:
  295.             createWakeOptions;
  296.             break;
  297.  
  298.         //    Return the command string.
  299.         //
  300.         case 2:
  301.             //    Get the command.
  302.             //
  303.             $cmd = `assembleCmd`;
  304.             break;
  305.     }
  306.     return $cmd;
  307. }
  308.  
  309.